logo of company

A Test Report for the Lumo Template


Subtitle with hyperlink

Author: Thomas Reinke

Date: October 3, 2024

Introduction

First paragraph

Second paragraph with bold text. Also an example hyperlink plus examplecode block.

Column margin with : hyperlink

Third paragraph

Load Packages

Section to load packages. Code is foled by default. You can adjust this behavior with the code-fold option in the document’s YAML header.

Code
library(tidyverse) 
library(hrbrthemes)
library(viridis)
library(ggiraph)
library(patchwork) 
library(sf)
theme_set(theme_minimal())
1
this package provides my favorite ggplot2 theme: theme_ipsum()

Example callout

Main Features

ggiraph example

Code
# Read the full world map
world_sf <- read_sf("https://raw.githubusercontent.com/holtzy/R-graph-gallery/master/DATA/world.geojson")
world_sf <- world_sf %>%
  filter(!name %in% c("Antarctica", "Greenland"))

# Create a sample dataset
happiness_data <- data.frame(
  Country = c(
    "France", "Germany", "United Kingdom",
    "Japan", "China", "Vietnam",
    "United States of America", "Canada", "Mexico"
  ),
  Continent = c(
    "Europe", "Europe", "Europe",
    "Asia", "Asia", "Asia",
    "North America", "North America", "North America"
  ),
  Happiness_Score = rnorm(mean = 30, sd = 20, n = 9),
  GDP_per_capita = rnorm(mean = 30, sd = 20, n = 9),
  Social_support = rnorm(mean = 30, sd = 20, n = 9),
  Healthy_life_expectancy = rnorm(mean = 30, sd = 20, n = 9)
)

# Join the happiness data with the full world map
world_sf <- world_sf %>%
  left_join(happiness_data, by = c("name" = "Country"))


# Create the first chart (Scatter plot)
p1 <- ggplot(world_sf, aes(
  GDP_per_capita,
  Happiness_Score,
  tooltip = name,
  data_id = Continent,
  color = Continent
)) +
  geom_point_interactive(data = filter(world_sf, !is.na(Happiness_Score)), size = 4) +
  theme_minimal() +
  theme(
    axis.title.x = element_blank(),
    axis.title.y = element_blank(),
    legend.position = "none"
  )

# Create the second chart (Bar plot)
p2 <- ggplot(world_sf, aes(
  x = reorder(name, Happiness_Score),
  y = Happiness_Score,
  tooltip = name,
  data_id = Continent,
  fill = Continent
)) +
  geom_col_interactive(data = filter(world_sf, !is.na(Happiness_Score))) +
  coord_flip() +
  theme_minimal() +
  theme(
    axis.title.x = element_blank(),
    axis.title.y = element_blank(),
    legend.position = "none"
  )

# Create the third chart (choropleth)
p3 <- ggplot() +
  geom_sf(data = world_sf, fill = "lightgrey", color = "lightgrey") +
  geom_sf_interactive(
    data = filter(world_sf, !is.na(Happiness_Score)),
    aes(fill = Continent, tooltip = name, data_id = Continent)
  ) +
  coord_sf(crs = st_crs(3857)) +
  theme_void() +
  theme(
    axis.title.x = element_blank(),
    axis.title.y = element_blank(),
    legend.position = "none"
  )

# Combine the plots
combined_plot <- (p1 + p2) / p3 + plot_layout(heights = c(1, 2))

# Create the interactive plot
interactive_plot <- girafe(ggobj = combined_plot)
interactive_plot <- girafe_options(
  interactive_plot,
  opts_hover(css = "fill:red;stroke:black;")
)

interactive_plot

Figure: three graphs connected thanks to ggiraph

Interactive table example

Code
library(DT)
data(iris)

# Make a table
datatable(iris, filter = "top")







CSS used to make text smaller in table

A grey section

Example gray section with LaTeX

\[ X \sim N(\mu, \sigma^2) \]

Quarto Tricks


Pill example, if you’re creating multiple plots, each highlighting different aspects of your dataset, consider using pills to organize them!